package ro.fortech.workshop_demo.access.webservice.apis;

import ro.fortech.workshop_demo.access.webservice.WSConstants;
import ro.fortech.workshop_demo.access.webservice.WebServiceManager;
import ro.fortech.workshop_demo.access.webservice.callbacks.GrandPrixParserDelegate;
import ro.fortech.workshop_demo.access.webservice.handlers.GrandPrixParser;
import ro.fortech.workshop_demo.utils.Utils;

/**
 * User: florinv
 * Date: 4/16/13
 * Time: 12:14 PM
 */
public class WSManagerSeasonsApi extends WebServiceManager {
    /**
     * Singleton instance
     */
    private static WSManagerSeasonsApi instance;

    /**
     * Private constructor
     */
    private WSManagerSeasonsApi() {

    }

    /**
     * Singleton instance retrieval method
     */
    public static WSManagerSeasonsApi getInstance() {
        if (instance == null) {
            instance = new WSManagerSeasonsApi();
        }
        return instance;
    }

    public void getGrandPrixList(String season, GrandPrixParserDelegate delegate) {
        // Build the url
        StringBuilder url = new StringBuilder(WSConstants.BASE_URL);
        url.append(season);

        // Instantiate the parser
        GrandPrixParser seasonsParser = new GrandPrixParser(delegate);

        // Make the call
        getRequest(Utils.getValidUrl(url.toString()), seasonsParser);
    }
}
